package com.piece.blog.repository.impl;

import com.piece.blog.model.ArticleInfo;
import com.piece.blog.repository.ArticleInfoRepository;
import com.piece.core.jpa.repository.BaseRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ArticleInfoRepositoryImpl extends BaseRepository<ArticleInfo, String> implements ArticleInfoRepository {

    /**
     * 根据文章ID查询文章详情
     */
    @Override
    public ArticleInfo findByArticle(Integer articleId) {
        ArticleInfo info = null;
        List<ArticleInfo> infos = findByCondition("articleId", articleId, null);
        if (null != infos && infos.size() > 0) {
            info = infos.get(0);
        }
        return info;
    }
}
